import request from '@/service/index'
import type {
  IContractList,
  IContractInfo,
  IContractImg,
  ISealSignature,
  IDragSign
} from './type'
// 待我签署
export const getContractSign = (params: IContractList) => {
  return request.get<any>({
    url: 'admin/contract/operatedByMe',
    params,
    showSuccess: false
  })
}
// 待我审批
export const getContractApprove = (params: IContractList) => {
  return request.get<any>({
    url: 'admin/contract/approval-process/receive-me',
    params,
    showSuccess: false
  })
}
// 他人操作
export const getContractOperation = (params: IContractList) => {
  return request.get<any>({
    url: 'admin/contract/operatedByOthers',
    params,
    showSuccess: false
  })
}
// 待我审批
export const getContractSuccess = (params: IContractList) => {
  return request.get<any>({
    url: 'admin/contract/complete',
    params,
    showSuccess: false
  })
}

// 获取合同信息
export const getContractAllInfo = (params: IContractInfo) => {
  return request.get<any>({
    url: 'admin/contract/contract-all-info',
    params
  })
}

// 获取合同图片
export const getContractBase64Img = (params: IContractImg) => {
  return request.get<any>({
    url: 'admin/contract/img/preview-base',
    params,
    showSuccess: false
  })
}

// 签署类型(固定||拖拽)
export const getContractSignType = (params: IContractInfo) => {
  return request.get<any>({
    url: 'admin/contract/get-contract-sealposition-count',
    params
  })
}

// 获取手绘签名
export const getSealSignatureList = (params: ISealSignature) => {
  return request.get<any>({
    url: 'admin/seal-signature/list',
    params,
    showSuccess: false
  })
}

// 拖拽签署
export const postDragSignData = (data: IDragSign) => {
  return request.post<any>({
    url: 'admin/contract/html/drag-signseal-h5',
    data
  })
}

// 固定签署
export const postFixedSignData = (data: IDragSign) => {
  return request.post<any>({
    url: 'admin/contract/html/signseal',
    data
  })
}

// 签署完成度
export const getSigningCompletion = (params: { contractId: string }) => {
  return request.get<any>({
    url: 'admin/contract/signing-completion',
    params
  })
}

// 普通用户签章模式
export const getSigningPattern = () => {
  return request.get<any>({
    url: 'admin/org-basic-info-config/get',
    showSuccess: false
  })
}

// 合同文件下载
export const getContractFileDownload = (params: { contractId: string }) => {
  return request.get<any>({
    url: 'admin/contract/contract-download-base',
    params,
    showSuccess: false
  })
}

// 添加印章签名
export const postSealSignature = (data: {
  sealId: number
  sealImage: string
}) => {
  return request.post<any>({
    url: 'admin/seal-signature/add-seal-sign',
    data,
    showSuccess: false
  })
}

// 获取系统时间
export const getSystemDate = () => {
  return request.get<any>({
    url: 'admin/home/get-system-date',
    showSuccess: false
  })
}

// 电子签名设置默认印章
export const postSettingsDefaultSeal = (data: FormData) => {
  return request.postForm<any>({
    url: 'admin/seal-signature/default',
    data
  })
}

// 电子签名删除
export const postRemoveSeal = (data: FormData) => {
  return request.postForm<any>({
    url: 'admin/seal-signature/remove-sign',
    data
  })
}

// 合同审批
export const postApprovalContract = (data: {
  processId: string
  contractId: string
  businessType: number
  approvalState: number
  remarks: string
}) => {
  return request.post<any>({
    url: 'admin/contract/approval-process/approval',
    data
  })
}
